package org.lds.scheduled.job.admin.business.job.model.request;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.StringUtils;
import org.lds.scheduled.job.common.model.db.request.BaseCreateRequest;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
 * 新建 - 请求
 *
 * @author lidongsheng
 * @since 2025-01-16
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Accessors(chain = true)
public class JobBaseCreateRequest extends BaseCreateRequest implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 应用ID
     */
    @NotNull(message = "appId不能为空")
    private Long appId;

    /**
     * 触发规则类型
     * 1: 固定频率（秒）
     * 2: CRON
     */
    private Integer triggerRuleType;

    /**
     * 触发规则内容
     */
    private String triggerRuleContent;

    /**
     * 名称
     */
    @NotBlank(message = "name不能为空")
    private String name;

    public void setName(String name) {
        this.name = StringUtils.trimToNull(name);
    }

}
